<template>
  <div class="home">
    <div class="home-left">
      <p>叁叁叁</p>
      <ul class="user">
        <li>
          <p>会员信息</p>
          <p>
            <span>账号：</span>
           
            <span>{{ JSON.parse(userMsg).account}}</span>
          </p>
          <p>
            <span>現金：</span>
            <span>{{ JSON.parse(userMsg).balance}}</span>
          </p>
          <p>
            <span>期号：</span>
            <span>{{msg.issue}}</span>
          </p>
        </li>
        <!-- <li>
          <p>澳5七星彩</p>
          <p>
            <span>编号</span>
            <span>号码</span>
            <span>赔率</span>
            <span>金额</span>
          </p>
          <p>笔数: 0 ,总金额: 0</p>
          <p></p>
          <el-button type="info" size="small">清空</el-button>
          <el-button type="info" size="small">打印</el-button>
          <p>第1321321期</p>
        </li>-->
      </ul>
    </div>
    <div class="home-right">
      <div class="home-right-top">
        <div>
          <div class @mouseenter="flag = true" @mouseleave="flag = false">
            <p v-if="this.typedt==1">河内五</p>
            <p v-if="this.typedt==2">澳洲五</p>
            <p v-show="flag">
              <span
                @click="nameClick(item.code)"
                v-for="(item,index) in module"
                :key="index"
              >{{ item.value}}</span>
            </p>
          </div>
          <!-- <div>
            
          </div>-->
          <el-menu
            :default-active="$route.path"
            class="el-menu-demo"
            mode="horizontal"
            router
            @select="handleSelect"
            background-color="#fff"
            text-color="#026fbb"
            active-text-color="#ffd04b"
          >
            <el-menu-item index="1" @click="homeTwo(titleid)">历史账单</el-menu-item>
            <el-menu-item index="2" @click="Dail(titleid)">日报表</el-menu-item>
            <el-menu-item index="3" @click="MonthlyReport(titleid)">月报表</el-menu-item>
            <el-menu-item index="/personalData">个人信息</el-menu-item>
            <span class="distance">距离 {{msg.issue}} 期封盘还有：{{msg.time}}</span>
            <div class="title_div">
              <span>会员：</span>
              <router-link tag="span" to="/personalData">{{ JSON.parse(userMsg).account}}</router-link>
              <router-link tag="span" to="/ChangePassword">修改密码</router-link>
              <span @click="open">退出</span>
            </div>
          </el-menu>
        </div>
        <!-- <div class="CountDown">
            <p>奥5七星彩</p>
            <p>asdfasdf咋都是个vadv佛山东莞VS电饭锅</p>
            <p>离50615008期停盘还有：0天0小时3分0秒</p>
        </div>-->
        <div class="about">
          <p>
            <router-link to="/Procedures" tag="span">规程说明</router-link>
            <span @click="lottery(titleid)" tag="span">开奖号码</span>
            <router-link to="/homeOne" tag="span">一字定</router-link>
            <span @click="Twosize(titleid)">二字定</span>
            <router-link to="/rollback" tag="span">快打</router-link>
            <span @click="totitle(titleid)">快选</span>
            <router-link to="/note" tag="span">下注明细</router-link>
            <!-- <span>txt导入</span> -->
            <span></span>
          </p>
        </div>
      </div>
      <div class="home-right-content">
        <!-- <div class="article-title">{{$route.name}}</div> -->
        <transition name="fade" mode="out-in">
          <router-view></router-view>
        </transition>
      </div>
    </div>
  </div>
</template>


<script>
import { mapState } from "Vuex";
export default {
  data() {
    return {
      isCollapse: false,
      activeIndex2: "0",
      flag: false,
      name: [],
      title: "河内五",
      issue: "",
      msg: {}, //时间
      titleid: "1",
      JSONdate:[],
      // user:this.$store.state.userMsg
    };
  },

  computed: {
    ...mapState(["module", "typedt", "showType","userMsg"]),
    // user() {
    //   return JSON.parse(this.$store.state.userMsg);
    // }
  },
  created() {
    this.detail();
    console.log(this.userMsg,78888)
  },
  watch: {
    "msg.time"() {
      if (this.msg.time == "--") {
        this.$store.commit("chaneShow", 2);
        setTimeout(() => {
          this.detail();
        }, 15000);
      }
    }
  },
  methods: {
    // 历史账单
    homeTwo(num) {
      this.$router.push({
        path: "homeTwo",
        query: {
          titleid: num
        }
      });
    },
    // 二字进
    Twosize(num) {
      this.$router.push({
        path: "Twosize",
        query: {
          titleid: num
        }
      });
    },
    // 点击快选
    totitle(num) {
      this.$router.push({
        path: "Quick",
        query: {
          titleid: num
        }
      });
    },
    Dail(num) {
      this.$router.push({
        path: "DailyReport",
        query: {
          titleid: num
        }
      });
    },
    MonthlyReport(num) {
      this.$router.push({
        path: "MonthlyReport",
        query: {
          titleid: num
        }
      });
    },
    lottery(num) {
      this.$router.push({
        path: "lottery",
        query: {
          titleid: num
        }
      });
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
    nameClick(name1) {
      this.$router.go(0)
      this.detail();
      console.log(321);
      // this.title = name; //名字
      this.titleid = name1; //id
      this.flag = false;
      console.log(this.titleid, 99999);
      this.$store.commit("typeid", this.titleid);
    },
    open() {
      this.$confirm("是否退出当前用户?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "退出成功!"
          });
          this.$store.commit("clearUserMsg");
          this.$router.push({ name: "login" });
          this.$router.push({ path: "/" });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
   
    // 接口当前期数
    detail() {
      this.$api.post(
        this.$url.current,
        {
          module: this.typedt
        },
        res => {
          this.msg = res.data.data;
          var time;
          if (this.msg.secondes >= 0) {
            time = setInterval(() => {
              var minutes = Math.floor(this.msg.secondes / 60);
              var seconds = Math.floor(this.msg.secondes % 60);
              var msg = minutes + "分" + seconds + "秒";
              --this.msg.secondes;
              if (this.msg.secondes < 0) {
                msg = "--";
                clearInterval(time);
                this.$store.commit("chaneShow", 2);
              } else {
                this.$store.commit("chaneShow", 1);
              }
              this.$set(this.msg, "time", msg);
            }, 1000);
          } else {
            this.$set(this.msg, "time", "--");
            setTimeout(() => {
              this.detail();
            }, 5000);
          }
        }
      );
    }
  }
};
</script>
<style lang="less" scope>
.distance {
  margin-left: 40px;
  position: relative;
  top: 18px;
  color: #999999;
  font-size: 14px;
}
@color1: #666;
.home {
  display: flex;
  justify-content: flex-start;

  height: 100%;
  .title_div {
    float: right;
    margin-right: 10%;
    line-height: 60px;
    span {
      padding: 0px 8px;
    }
    span:hover {
      padding: 0px 8px;
      color: #409eff;
    }
  }
  .title span {
    color: #fff;
    line-height: 60px;
    padding: 0px 10px;
  }
  .title span:hover {
    color: rgb(255, 208, 75);
    line-height: 60px;
  }
  .home-left {
    height: 100%;
    width: 15%;
    // padding: 0px 10px;
    box-sizing: border-box;
    min-width: 200px;
    > p {
      height: 60px;
      text-align: center;
      line-height: 56px;
      font-weight: bold;
      font-size: 18px;
      //   border-right: 1px solid #eee;
      color: #fff;
      background: rgb(84, 92, 100);
    }
    .user {
      width: 96%;
      margin: 0px 2%;
      li {
        margin: 20px 0px;
        text-align: center;
        line-height: 20px;
        border: 1px solid #999;
        p {
          line-height: 25px;
        }
      }
      li:nth-child(1) {
        p:nth-child(1) {
          color: #eee;
          background: rgb(97, 95, 95);
        }
      }
      li:nth-child(2) {
        p:nth-child(1) {
          color: red;
          background: #fff;
          font-weight: 700;
        }
        p {
          span {
            padding: 2px;
            border: 1px solid #999;
          }
        }
      }
    }
  }
  .home-right {
    width: 85%;
    max-width: 85%;
    .home-right-top {
      // display: flex;
      // justify-content: space-between;
      width: 100%;
      align-items: center;
      border-bottom: 1px solid #eee;
      div {
        div:first-child {
          // display: inline-block;
          width: 10%;
          height: 60px;
          float: left;
          background: rgb(226, 167, 134);
          z-index: 999;
          p {
            line-height: 60px;
            text-align: center;
            color: #fff;
            font-size: 18px;
            font-weight: 700;
          }
          p:last-child {
            background: #fea930;
            z-index: 999;
            position: absolute;
            padding: 0 15px;
            span {
              padding: 5px 25px;
            }
          }
        }
        ul {
          width: 90%;
          margin-left: 10%;
        }
      }
      .CountDown {
        width: 100%;
        p {
          width: 30%;
          display: inline-block;
        }
      }
      .about {
        background: rgb(226, 167, 134);
        height: 50px;
        z-index: 1;
        span,
        p {
          line-height: 50px;
          padding: 2px 5px;
          color: #fff;
          z-index: 1;
        }
        span {
          z-index: 1;
        }
      }
    }
    .home-right-content {
      margin: 4px;
      // border: 1px solid #eee;
      .article-title {
        font-size: 18px;
        padding: 0 0 10px;
        margin-bottom: 10px;
        color: @color1;
        border-bottom: 1px solid @color1;
      }
    }
  }
}
</style>